#!/usr/bin/python3
# 文件名：server.py
import _thread
import mysql.connector

# 导入 socket、sys 模块
import socket
import sys

# 创建 socket 对象
serversocket = socket.socket(
    socket.AF_INET, socket.SOCK_STREAM)

# 获取本地主机名
host = socket.gethostname()

xxx="asd\nadsg"
print(xxx)

port = 9999

# 绑定端口号
serversocket.bind((host, port))

# 设置最大连接数，超过后排队
serversocket.listen(5)
clientsocket, addr = serversocket.accept()

while True:
    # 建立客户端连接
    print("连接地址: %s" % str(addr))
    msgx = clientsocket.recv(1024)
    print(msgx.decode('utf-8'))
    msg = '登陆成功 ！' + "\r\n"
    clientsocket.send(msg.encode('utf-8'))
    #clientsocket.close()